package com.jianganming.clone;

import javax.swing.*;
import java.awt.*;

public class SunWukong extends JPanel implements Cloneable {
    public SunWukong(){
        JLabel jPanel = new JLabel(new ImageIcon("images/wukong.jpg"));
        this.add(jPanel);
    }

    @Override
    protected SunWukong clone() throws CloneNotSupportedException {
        return (SunWukong)super.clone();
    }
}

class ProtoTypeWukong{
    public static void main(String[] args)throws CloneNotSupportedException {
        JFrame jFrame = new JFrame("复制孙悟空");
        jFrame.setLayout(new GridLayout(1,2));
        Container container = jFrame.getContentPane();
        SunWukong wukong = new SunWukong();
        container.add(wukong);
        container.add(wukong.clone());
        jFrame.pack();
        jFrame.setVisible(true);
        jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
}
